/*
 * 易族智汇（北京）科技有限公司 版权所有。
 * 未经许可，您不得使用此文件。
 * 官方地址：www.javamall.com.cn
 */
package com.enation.app.javashop.core.client.fallback.system;

import com.enation.app.javashop.core.client.feignimpl.system.SmsClientFeignImpl;
import com.enation.app.javashop.core.handler.BaseFallbackFactory;
import com.enation.app.javashop.model.base.SceneType;
import com.enation.app.javashop.model.base.vo.SmsSendVO;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.cloud.openfeign.FallbackFactory;
import org.springframework.stereotype.Component;

/**
 * @author fk
 * @version v2.0
 * @Description: 发短信客户端断路器
 * @date 2018/9/27 14:20
 * @since v7.0.0
 */
@Component
public class SmsClientFallbackFactory extends BaseFallbackFactory<SmsClientFeignImpl> implements FallbackFactory {


    @Override
    protected SmsClientFeignImpl fallback() {
        return new SmsClientFallback();
    }

    /**
     * @author fk
     * @version v2.0
     * @Description: 发短信客户端断路器
     * @date 2018/9/27 14:20
     * @since v7.0.0
     */
    @Component
    public static class SmsClientFallback implements SmsClientFeignImpl {

        protected final Log logger = LogFactory.getLog(this.getClass());

        @Override
        public boolean valid(String scene, String mobile, String code) {

            this.logger.error("系统服务异常，验证验证码异常");

            return false;
        }

        @Override
        public String validMobile(String scene, String mobile) {
            return null;
        }

        @Override
        public void sendSmsMessage(String byName, String mobile, SceneType sceneType) {

            this.logger.error("系统服务异常，发送短信1异常");
        }

        @Override
        public void send(SmsSendVO smsSendVO) {

            this.logger.error("系统服务异常，发送短信2异常");

        }
    }
}
